<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UserController extends Controller
{
    //
    public function login()
    {
        return view("user.login");
    }

    public function check()
    {
        $user = request(['name','password']);
        if (\Auth::attempt($user,true)){
            return [
                'error'=>0,
                'info'=>'登陆成功',
            ];
        }
        return [
            'error'=>1,
            'info'=>'账号或密码错误',
        ];
    }

    public function logout()
    {
        \Auth::logout();
        return redirect("/login");
    }

    public function index()
    {
        return view('user.index');
    }
}
